Skip to content

feat: oss index collections endpoint - #2352

Merged
epipav merged 5 commits into
mainfrom
feat/IN-1416
Oct 14, 2026
Merged

epipav merged 5 commits into
mainfrom
feat/IN-1416

Conversation

@epipav

@epipav epipav commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds GET /v1-alpha/oss-index/collections (IN-1416, epic IN-1146). It returns a cursor-paged list of OSS Index collections with their top projects, plus the category details when a category is picked.

  • categorySlug and categoryGroupId filter the collections. sort (totalContributors or softwareValue, default totalContributors) orders them. cursor and pageSize page them like the leaderboard routes.
  • With categorySlug, the route reads the category from category_list first and returns it as category. An unknown slug answers 404 not_found, and the collections pipe is then skipped.
  • Collections come from collections_oss_index. Their project tuples carry slug, so src/lib/oss-index.ts gains CollectionProject and its guard and mapper. Collection projects carry the same v2 health fields as the other OSS Index endpoints.
  • An invalid cursor answers 400. A malformed row answers 503 upstream_unavailable.

Notes

  • The pipe's total row count ignores the category filter, so the route detects the last page from a short pipe page. A full last page may return a nextCursor that leads to an empty page.
  • Counts and software values must be non-negative integers, matching the groups and categories endpoints.
  • Stacked on feat: oss index categories endpoint #2351.

Tests

  • tests/oss-index-collections.test.ts: filter and sort forwarding, the category lookup and 404, tuple mapping, paging across pipe pages with the cursor walk, 400 for bad input, 503 for malformed rows, and the OpenAPI entry.
  • tests/oss-index.test.ts: the 14-slot guard and mapper.

Copilot AI balanced review requested due to automatic review settings October 1, 2026 13:15
@cursor

cursor Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
New read-only API surface with multi-upstream orchestration and non-obvious pagination when category filters are applied; follows established OSS Index patterns with strict row validation.

Overview
Adds GET /v1-alpha/oss-index/collections, a cursor-paged list of OSS Index collections (totals, topProjects, optional category metadata) backed by Tinybird pipes collections_oss_index and category_list.

oss-index.ts gains CollectionProject support for the collections pipe’s 14-slot project tuples (slug inserted before status): isCollectionProjectTuple, toCollectionProject, and a TypeBox schema extending TopProject with slug.

The route accepts categorySlug / categoryGroupId filters and sort (totalContributors or softwareValue). With categorySlug, it resolves the category first (404 not_found and skips the collections pipe if missing), then includes category on the response. Pagination matches other OSS Index leaderboard routes; nextCursor may point to an empty page when the last pipe page is full because upstream totals ignore the category filter. Malformed upstream rows yield 503 upstream_unavailable.

Tests cover mapping, query forwarding, category 404/503, paging/cursor walks, validation 400s, and OpenAPI; unit tests cover the new tuple guard and mapper.

Reviewed by Cursor Bugbot for commit 5cf72de. Bugbot is set up for automated code reviews on this repo. Configure here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The endpoint contract and failure paths are well covered; only a non-blocking comment wording issue remains.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Adds the cursor-paginated OSS Index collections endpoint with filtering, category details, validation, and tuple mapping.

Changes:

  • Adds GET /v1-alpha/oss-index/collections.
  • Introduces collection-project schemas, guards, and mappers.
  • Adds integration and pagination coverage.
File Description
api/​src/​versions/​v1-alpha/​oss-index/​collections.ts Implements the endpoint and schema.
api/​src/​lib/​oss-index.ts Adds collection-project utilities.
api/​tests/​oss-index-collections.test.ts Tests endpoint behavior and pagination.
api/​tests/​oss-index.test.ts Tests tuple validation and mapping.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread api/src/lib/oss-index.ts Outdated
Copilot AI balanced review requested due to automatic review settings October 1, 2026 13:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The documented full-page cursor guarantee does not hold for mid-page cursors.

Review effort: Balanced
Findings: None

Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Low severity Incorrectly nullifies nextCursor for short cursor pages

api/​src/​versions/​v1-alpha/​oss-index/​collections.ts:135

This guarantee is too broad: with pageSize=2, cursor offset 1, and three rows total, the second pipe page is short and this handler returns nextCursor: null despite returning two rows. Document that only some full final responses produce an empty follow-up page.

@epipav
epipav added this pull request to stack #2380 October 14, 2026 11:23
Copilot AI balanced review requested due to automatic review settings October 14, 2026 11:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The strict 10-slot guard rejects current 14-slot Tinybird tuples, causing valid responses to return 503.

2 open findings

🧠 Review effort: Balanced

Comment thread api/src/lib/oss-index.ts Outdated
Comment thread api/src/versions/v1-alpha/oss-index/collections.ts Outdated

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread api/src/lib/oss-index.ts Outdated
Copilot AI balanced review requested due to automatic review settings October 14, 2026 12:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation is consistent with related routes and has comprehensive coverage for its documented behavior.

0 open findings

2 resolved since last review

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 14, 2026 12:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the stated contract and includes thorough coverage of its validation, mapping, and pagination behavior.

0 open findings

🧠 Review effort: Balanced

@epipav

epipav commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Copilot AI balanced review requested due to automatic review settings October 14, 2026 13:13
@epipav

epipav commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the described contract and includes comprehensive validation and tests.

0 open findings

🧠 Review effort: Balanced

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit c36ae29. Configure here.

Copilot AI balanced review requested due to automatic review settings October 14, 2026 15:14
Base automatically changed from feat/IN-1415 to main October 14, 2026 15:15
Signed-off-by: anilb <epipav@gmail.com>
Signed-off-by: anilb <epipav@gmail.com>
Signed-off-by: anilb <epipav@gmail.com>
Signed-off-by: anilb <epipav@gmail.com>
Signed-off-by: anilb <epipav@gmail.com>
@epipav epipav self-assigned this Oct 14, 2026
@epipav
epipav merged commit b22f936 into main Oct 14, 2026
12 checks passed
@epipav
epipav deleted the feat/IN-1416 branch October 14, 2026 15:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the stated contract and includes strong validation, pagination, error-path, and OpenAPI coverage.

0 open findings

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 14, 2026 15:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the described contract and includes comprehensive validation and tests.

0 open findings

🧠 Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants